# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: emersion <contact emersion fr>

pkgname=libvarlink
pkgver=23
pkgrel=1
license=('MIT')
pkgdesc='Varlink C library and command line tool'
makedepends=('meson')
arch=('loong64' 'x86_64')
url='https://github.com/varlink/libvarlink'
source=("https://github.com/varlink/libvarlink/archive/$pkgver/$pkgname-$pkgver.tar.gz")
sha256sums=('a5575e070e446e7c4486d424393950e6cb7a3b376ee20d517b0c13a876659a8d')

build() {
  cd "$pkgname-$pkgver"
  meson --prefix=/usr build/
  ninja -C build/

  # convert thin archive to fat one
  ar -t build/lib/libvarlink.a | xargs ar rs build/lib/libvarlink.a.new
  mv build/lib/libvarlink.a{.new,}
}

check() {
  cd "$pkgname-$pkgver"
  ninja -vC build/ test
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm 644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
  DESTDIR="$pkgdir/" ninja -C build/ install
}
